<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<h1>距离五一还有</h1>
	<span></span>天
	<span></span>时
	<span></span>分
	<span></span>秒
	<script type="text/javascript">
		let span = document.querySelectorAll('span')

		function time() {
			let now = new Date().getTime()
			let endTime = new Date("2025/5/1, 00:00:00").getTime()
			//获取5.1到现在的时间差
			let diff = endTime - now
			console.log(diff)

			let day = parseInt(diff/1000/60/60/24)
			let hour = parseInt(diff/1000/60/60%24)
			let minute = parseInt(diff/1000/60%60)
			let second = parseInt(diff/1000%60)

			hour = hour < 10 ? '0' + hour : hour
			minute = minute < 10 ? '0' + minute : minute
			second = second < 10 ? '0' + second : second


			span[0].innerText = day
			span[1].innerText = hour
			span[2].innerText = minute
			span[3].innerText = second
		}
		time()
		setInterval(time,1000)
	</script>
</body>
</html>